package com.example.drawex;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class BitmapMatrixView extends View {
	
	// 회전 방향에 대한 행렬값
	
	int matX = 1;
	int matY = 1;

	public BitmapMatrixView(Context context, AttributeSet attr) {
		super(context, attr);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {

		// 원본 이미지
		Paint paint = new Paint();
		Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.bang2011);
		
		
		Matrix mat = new Matrix();
		mat.preScale(matX, matY);
		
		
		// 회전된 이미지 생성
		Bitmap matMap = Bitmap.createBitmap(
				map, 0, 0, 
				map.getWidth(), map.getHeight(), 
				mat, false);
		
		canvas.drawBitmap(map, 10, 10, null);
		canvas.drawBitmap(matMap, 110, 110, null);
		
		super.onDraw(canvas);
	}
	
	
	public void setMatrix(int matX, int matY) {
		this.matX = matX;
		this.matY = matY;
		invalidate();
	}
	
}
